<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="add">add</button>
    <h3 v-for="(item,index) in arr" :key="index">
      {{item}}
      <button @click="del(index)">del</button>
    </h3>
  </div>

  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      },
      methods: {
        del(index) {
          this.arr.splice(index, 1)
          console.log(this.arr);

        },
        add() {
          this.arr.push(this.arr.length + 1);
        },
      }
    })
  </script>



  <!-- 原始key:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] -->
  <!-- 删除8之后的key: [0, 1, 2, 3, 4, 5, 6, 7, 9] -->
  <!-- 添加上一个之后的key: [0, 1, 2, 3, 4, 5, 6, 7, 9, 9] -->
</body>

</html>